﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Linq.Expressions;
using Newtonsoft.Json.Linq;

using CanDoo;
using CanDoo.Core;
using CanDoo.Data;
using CanDoo.Web;
using CanDoo.FineUI;
using CanDoo.Extensions;
using CanDoo.Oil.Core.Models;
using CanDoo.Oil.Core.Contracts;
using CanDoo.Admin.Core.Contracts;
using FineUIPro;

namespace CanDoo.Oil.WebApp.sellOutSellBackDetail
{
    public partial class Edit : EditPagebase<IOutSellBackDetailContract, OutSellBackDetail>
    {
        public IOutSellBackContract OutSellBackContract { get; set; }
        public IOutStoreDetailContract OutStoreDetailContract { get; set; }
        public IProductContract ProductContract { get; set; }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (PageMode != pagemode.Add)
                    LoadData();
            }
        }

        protected override void LoadData(OutSellBackDetail entity)
        {
            ed_Name.SetValue(entity.Name);
            ed_Price.SetValue(entity.Price);
            ed_Num.SetValue(entity.Num);
            ed_Money.SetValue(entity.Money);
            ed_AlreadyNum.SetValue(entity.AlreadyNum);
            ed_AlreadyMoney.SetValue(entity.AlreadyMoney);
            ed_Coefficient.SetValue(entity.Coefficient);
            ed_Remark.SetValue(entity.Remark);
        }

        protected override OperationResult SaveData(OutSellBackDetail entity)
        {
            entity.Name = ed_Name.GetValue().ToString();
            entity.Price = ed_Price.GetValue().ToDouble();
            entity.Num = ed_Num.GetValue().ToDouble();
            entity.Money = ed_Money.GetValue().ToDouble();
            entity.AlreadyNum = ed_AlreadyNum.GetValue().ToDouble();
            entity.AlreadyMoney = ed_AlreadyMoney.GetValue().ToDouble();
            entity.Coefficient = ed_Coefficient.GetValue().ToInt();
            entity.Remark = ed_Remark.GetValue().ToString();
            return base.SaveData(entity);
            
        }
    }
}
